package com.eastfair.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 用户类型枚举类
 * 
 * </p>
 *
 * @author zjn
 * @date 2021-07-29
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SubjectTypeEnum", description = "使用主体 #{VISITOR:观众;ACTOR:展商;SPONSOR:主办-枚举")
public enum SubjectTypeEnum implements BaseEnum {
    /**
     * 员工
     */
    EMPLOYEE("员工"),
    /**
     * VISITOR="观众"
     */
    VISITOR("观众"),
    /**
     * ACTOR="展商"
     */
    ACTOR("展商"),
    /**
     * SPONSOR="主办"
     */
    SPONSOR("主办"),
    COMPANY("公司"),
    PRODUCT("产品"),
    EXHIBITOR_PRODUCT("展品"),
    BUSINESS_CIRCLE("商脉圈"),
    APPOINTMENT("商贸对接"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static SubjectTypeEnum match(String val, SubjectTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SubjectTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(SubjectTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "VISITOR,EXHIBITOR,SPONSOR", example = "VISITOR")
    public String getCode() {
        return this.name();
    }

}
